<template>
  <div style="width: 100%; height: 100%">
    <vxe-grid  v-bind="gridOptions" >
      <template #toolbar_buttons>

      </template>
      <template #action="{ row }">
        <TableAction outside :actions="[
          {
              label:'查看',
              onClick: handleEdit.bind(null, row),
          },

        ]
        " />
      </template>
    </vxe-grid>
    <FormModal @register="register" />

  </div>
</template>
<script lang="ts" setup>
import {
  BasicTableProps,
  VxeBasicTable,
  VxeGridInstance,
  VxeGridListeners,
  VxeTableDefines,
} from '@/components/VxeTable';

import { getQualifiedList } from '@/api/sys/sysData';
import { useDrawer } from '@/components/Drawer';
import util from '@/utils/util';

import {onMounted, reactive, ref} from 'vue';

import { useMessage } from "@/hooks/web/useMessage";
import { useGo } from "@/hooks/web/usePage";
import {vxeTableColumns,vxeTableFormSchema} from "./role.data";
import {TableAction} from "@/components/Table";
import FormModal from "./FormModal.vue";

const go = useGo();

defineOptions({ name: 'ywDeptList' });
const { createMessage } = useMessage();

// const [register, { openModal, closeModal }] = useModal();
const [register, { openDrawer,closeDrawer }] = useDrawer();

const gridOptions = reactive<BasicTableProps>({
  // keepSource: true,
  editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
  border: true,
  showOverflow: true,
  size: 'mini',
  height: 'auto', // 'auto'
  mergeCells: [
  ],
  columns: vxeTableColumns,
  filterConfig: {
    remote: true,
  },
  toolbarConfig: {
    enabled: false,
    slots: {
      buttons: 'toolbar_buttons',
      tools:'tool_ref'
    },
  },
  formConfig: {
    items: vxeTableFormSchema,
  },
  pagerConfig: {
    // pageSize: 50,
    enabled: false,
  },
  proxyConfig: {
    props: {
      result: 'data.list',
      list: 'data.list',
      total: 'data.totalResult',
      message: 'message',
    },
    filter: true,
    ajax: {
      query: ({ page, form, filters }) => {
        return findPageList(page, form, filters);
      },
    },
  },

});


const loading=ref(false);
const msgList = ref([]);


const applyViewShow = ref(false);

const tableRef = ref<VxeGridInstance>();

const formData=ref({
  year:util.times("year")+"-01-01"
});

function findPageList(page, form, filterList?: VxeTableDefines.FilterCheckedParams<any>[]) {
  let json = {};
  if (filterList && filterList.length) {
    filterList.forEach((e) => {
      const value = e.datas[0];
      let field = e.field;
      json[field + 'Like'] = value;
    });
  }
  // console.log("----json:", json);
  // ywApproveList xftList
  return getQualifiedList({
    page: page.currentPage,
    pageSize: page.pageSize,
    ...form,
    ...json,
  });
}


function handleCreate() {
  openDrawer(true, {
    isUpdate: false,
  });
}




function handleEdit(record: Recordable) {
  record.isUpdate=true;
  openDrawer(true, record);

}



function handleDelete(record: Recordable) {
}





</script>
<style lang="less">
.my-table{
  //width: 40%;
  margin-bottom: 5px;
  margin-top: 5px;
}
</style>
